<template>
  <div class="title">
    <img src="@/assets/images/personal_center/goback.png" alt="" @click="goBack">
    <span>{{ title }}</span>
    <span v-if="subtitle" class="subtitle" @click="goSubPath">{{ subtitle }}</span>
  </div>
</template>

<script>
export default {
  name: 'toBar',
  props: {
    title: String,
    goIndex: Boolean,
    subtitle: String,
    subPath: String
  },
  methods: {
    // 返回上一步
    goBack () {
      if (this.goIndex) {
        this.$router.push({path: '/me/index'})
      } else {
        this.$router.go(-1)
      }
    },
    goSubPath () {
      if (this.subPath) {
        this.$router.push({path: this.subPath})
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.title {
  display: flex;
  align-items: center;
  margin-bottom: 0.27rem;

  img {
    width: 0.48rem;
    height: 0.37rem;
    float: left;
  }

  > span:nth-child(2) {
    margin-left:2rem;
    text-align: center;
    width: 4rem;
    font-size: 0.43rem;
    font-family: SourceHanSansCN-Bold, SourceHanSansCN;
    font-weight: bold;
    color: #292934;
  }

  > span:nth-child(3) {
    font-size: 0.3rem;
    color: #999999;
    flex: 1;
    text-align: right;
    padding-right: 0.4rem;
  }
}
</style>
